<?php
class Database {
	private $__config = array();
	private $__conn;
	function __construct($config){
		$this->__config = &$config;
	}
	
	function __destruct(){
		//$this->destroyConnection();
	}
	
	public function createConnection(){
		$c = $this->__config->get('DB');
		$this->__conn = mysql_connect($c->get('DBHOST'), $c->get('USER'), $c->get('PASS'));
		
		mysql_select_db($c->get('DBNAME'), $this->__conn);
		return $this->__conn;
	}
	
	public function destroyConnection(){
		mysql_close($this->__conn);
	}
	
	public function query($sql){
		
		return mysql_query($sql, $this->__conn);
	}
	
	public function fetch_array($sql){
		$q = $this->query($sql);
		$res = array();
		while ($d = mysql_fetch_array($q)){
			 $res[] = $d;
		}
		return $res;
	}
	
}
?>